﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace RoyTools.D3Monitor.FormUI.Helper
{
    /// <summary>
    /// 窗体辅助类
    /// </summary>
    public class FormHelper
    {
        /// <summary>
        /// 显示
        /// </summary>
        /// <param name="form"></param>
        public static void Show<T>(T form) where T : Form
        {
            if (form == null)
            {
                form = (T)Activator.CreateInstance(typeof(T));
            }
            form.ShowDialog();
        }

        /// <summary>
        /// 隐藏
        /// </summary>
        /// <param name="form"></param>
        public static void Hide<T>(T form) where T : Form
        {
            if (form != null)
            {
                form.Hide();
            }
        }

        /// <summary>
        /// 关闭
        /// </summary>
        /// <param name="form"></param>
        public static void Close<T>(T form) where T : Form
        {
            if (form != null)
            {
                form.Close();
            }
        }
    }
}
